package com.ruoyi.report.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.report.domain.ReportSelfPickupCustomer;
import com.ruoyi.report.service.IReportSelfPickupCustomerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 自提油客户管理Controller
 * 
 * @author scp
 * @date 2024-10-11
 */
@RestController
@RequestMapping("/report/selfPickup")
public class ReportSelfPickupCustomerController extends BaseController
{
    @Autowired
    private IReportSelfPickupCustomerService reportSelfPickupCustomerService;

    /**
     * 查询自提油客户管理列表
     */
    @PreAuthorize("@ss.hasPermi('report:selfPickup:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReportSelfPickupCustomer reportSelfPickupCustomer)
    {
        startPage();
        List<ReportSelfPickupCustomer> list = reportSelfPickupCustomerService.selectReportSelfPickupCustomerList(reportSelfPickupCustomer);
        return getDataTable(list);
    }


    @GetMapping("/listNoPage")
    public TableDataInfo listNoPage(ReportSelfPickupCustomer reportSelfPickupCustomer)
    {
        List<ReportSelfPickupCustomer> list = reportSelfPickupCustomerService.selectReportSelfPickupCustomerList(reportSelfPickupCustomer);
        return getDataTable(list);
    }

    /**
     * 导出自提油客户管理列表
     */
    @PreAuthorize("@ss.hasPermi('report:selfPickup:export')")
    @Log(title = "自提油客户管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ReportSelfPickupCustomer reportSelfPickupCustomer)
    {
        List<ReportSelfPickupCustomer> list = reportSelfPickupCustomerService.selectReportSelfPickupCustomerList(reportSelfPickupCustomer);
        ExcelUtil<ReportSelfPickupCustomer> util = new ExcelUtil<ReportSelfPickupCustomer>(ReportSelfPickupCustomer.class);
        return util.exportExcel(list, "自提油客户管理数据");
    }

    /**
     * 获取自提油客户管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('report:selfPickup:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(reportSelfPickupCustomerService.selectReportSelfPickupCustomerById(id));
    }

    /**
     * 新增自提油客户管理
     */
    @PreAuthorize("@ss.hasPermi('report:selfPickup:add')")
    @Log(title = "自提油客户管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReportSelfPickupCustomer reportSelfPickupCustomer)
    {
        return toAjax(reportSelfPickupCustomerService.insertReportSelfPickupCustomer(reportSelfPickupCustomer));
    }

    /**
     * 修改自提油客户管理
     */
    @PreAuthorize("@ss.hasPermi('report:selfPickup:edit')")
    @Log(title = "自提油客户管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReportSelfPickupCustomer reportSelfPickupCustomer)
    {
        return toAjax(reportSelfPickupCustomerService.updateReportSelfPickupCustomer(reportSelfPickupCustomer));
    }

    /**
     * 删除自提油客户管理
     */
    @PreAuthorize("@ss.hasPermi('report:selfPickup:remove')")
    @Log(title = "自提油客户管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(reportSelfPickupCustomerService.deleteReportSelfPickupCustomerByIds(ids));
    }
}
